#pragma once
#include "BaseRebot.h"
#include "XMsg.h"

#include <map>
using namespace std;

class ManagerRebot:public Rebot, public CSingleton<ManagerRebot>, public CThread
{
public:
	
	~ManagerRebot(void);

protected:
	ManagerRebot();

public:
	virtual void Updata();
	virtual void OnTime(long long llTimeBegin);
	virtual void PrintInfo();

public:
	virtual unsigned int ProcFun();
	virtual unsigned ThreadProc();

	virtual unsigned int Init();
	virtual unsigned int Close();
	virtual int OnInsideRead(InsideMsg* pMsg);
public:
	void	PushInsideMsg(InsideMsg* pmg);
	Rebot* CreateRebot(string&  strName);
	bool	ReleaseRobot(Rebot* pRobot);
	void   RegisterRebot(string& strName, Rebot* prt);
	void   CommandLine(char*  commandline);

	DATA_ACCESS_ALLOW(ManagerRebot);
private:
	virtual void Load();
private:
	//map<string, Rebot*>   mAllRebotMap;
	map<long long, Rebot*>   mRegistRebotMap;
	CLock				  mapLock;	
	list<InsideMsg*>	  mInsideMsgList;
	CLock				  lstLock;

	bool                  mThreadRun;

};

